import org.I0Itec.zkclient.ZkClient;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
/**
 * 启动初始化，创建数据库连接池并监听
 */
public class Startup {
    //加载zk中数据库配置信息
    ZkClient zkClient = new ZkClient("linux121:2181,linux122:2181,linux123:2181");
    String cfg = zkClient.readData("/webapp/dblinkcfg", true);
    Properties pro = new Properties();
        Utils.loadData(pro, cfg);
    //创建数据库连接池
    Utils.createDbPool(pro);
    //监听数据库连接池
    Listener.monitor();
    //测试
    Connection conn = ConnectionManager.getConnection();
    PreparedStatement preparedStatement = conn.prepareStatement("select * from execution_jobs");
    ResultSet resultSet = preparedStatement.executeQuery();
        if (resultSet.next()) {
        System.out.println(resultSet.getString("flow_id"));
        System.out.println(resultSet.getString("job_id"));
    }
}
